import React from "react";
import PropTypes from "prop-types";
import {Link} from "react-router-dom";
import WebFont from "../../base/Font";

/**
 *  Menu Item Component
 */
export default class Item extends React.Component
{
    static defaultProps =
    {
        item : {}
    };

    static propTypes =
    {
        item : PropTypes.shape({
            icon : PropTypes.string,
            url : PropTypes.string,
            title : PropTypes.string.isRequired
        })
    };

    render ()
    {
        if (this.props.item.icon) {
            return <li>
                <Link to={this.props.item.url}>
                    <WebFont icon={this.props.item.icon}/>&nbsp;
                    {this.props.item.title}
                </Link>
            </li>
        }

        return <li>
            {this.props.item.title}
        </li>
    }
}